package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.TbServicePackage;
import com.ruoyi.system.service.ITbServicePackageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 服务套餐管理Controller
 * 
 * @author hkj
 * @date 2024-09-10
 */

@RestController
@RequestMapping("/package")
public class TbServicePackageController extends BaseController
{
    @Autowired
    private ITbServicePackageService tbServicePackageService;

    /**
     * 查询服务套餐管理列表
     */
//    @RequiresPermissions("system:package:list")
    @GetMapping("/list")
    public TableDataInfo list(TbServicePackage tbServicePackage)
    {
        startPage();
        List<TbServicePackage> list = tbServicePackageService.selectTbServicePackageList(tbServicePackage);
        return getDataTable(list);
    }

    /**
     * 导出服务套餐管理列表
     */
    @RequiresPermissions("system:package:export")
    @Log(title = "服务套餐管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbServicePackage tbServicePackage)
    {
        List<TbServicePackage> list = tbServicePackageService.selectTbServicePackageList(tbServicePackage);
        ExcelUtil<TbServicePackage> util = new ExcelUtil<TbServicePackage>(TbServicePackage.class);
        util.exportExcel(response, list, "服务套餐管理数据");
    }

    /**
     * 获取服务套餐管理详细信息
     */
    @RequiresPermissions("system:package:query")
    @GetMapping(value = "/{packageId}")
    public AjaxResult getInfo(@PathVariable("packageId") Long packageId)
    {
        return success(tbServicePackageService.selectTbServicePackageByPackageId(packageId));
    }

    /**
     * 新增服务套餐管理
     */
    @RequiresPermissions("system:package:add")
    @Log(title = "服务套餐管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbServicePackage tbServicePackage)
    {
        return toAjax(tbServicePackageService.insertTbServicePackage(tbServicePackage));
    }

    /**
     * 修改服务套餐管理
     */
    @RequiresPermissions("system:package:edit")
    @Log(title = "服务套餐管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbServicePackage tbServicePackage)
    {
        return toAjax(tbServicePackageService.updateTbServicePackage(tbServicePackage));
    }

    /**
     * 删除服务套餐管理
     */
    @RequiresPermissions("system:package:remove")
    @Log(title = "服务套餐管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packageIds}")
    public AjaxResult remove(@PathVariable Long[] packageIds)
    {
        return toAjax(tbServicePackageService.deleteTbServicePackageByPackageIds(packageIds));
    }
}
